home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0867.dms / q0867.adf / TRAPDOOR.LZH / Rexx / TrimDir.rexx < prev    next >
OS/2 REXX Batch file  |  1991-01-16  |  845b  |  36 lines

  1. /* Trim a directory
  2.  
  3.    Usage: rx TrimDir <dir> <days>
  4.  
  5.    Delete all files in the given directory <dir> that are older than <days>
  6.    days. The <dir> parameter may also contain a pattern specification to
  7.    select only certain files from the directory.
  8. */
  9.  
  10. CSI     = '9b'x
  11. OFF     = CSI'0m'
  12. BO     = CSI'1m'
  13. UL     = CSI'4m'
  14. KEOL = CSI'K'
  15. CR   = '0d'x
  16. LF   = '0a'x
  17.  
  18. parse arg dir days
  19.  
  20. if days<=0 then do
  21.     say "TrimDir.rexx: bad args"
  22.     return 10
  23. end
  24.  
  25. call writech(stdout, 'Trimming' dir)
  26. call writech(stdout, ',' days 'days')
  27. date=space(date('n',date('i')-days),1,'-')
  28. date=left(overlay(substr(date,10,2),date,8,2),9)
  29. call writech(stdout, ',' date)
  30. address command 'list >t:TrimDir.temp' dir 'upto' date 'lformat "delete %s%s quiet"'
  31. address command 'execute t:TrimDir.temp'
  32. address command "delete t:TrimDir.temp quiet"
  33. call writech(stdout, LF)
  34.  
  35. return 0
  36.